<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">

   
    //要求输入一串低于10位的数字，输出对应的中文大写:
//例： input: 10001-- > 一万零一     ；   input:  10, 000, 000-- > 一千万

    
    var strNumber = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '拾'];
    var numberOfWeight = ['', '拾', '佰', '仟', '万', '拾', '佰', '仟', '亿'];
    var num = prompt("请输入一串低于10位的数字");

    chineseNumber(num);

    function chineseNumber(num) {

        var onum = num;
        if (onum == 0) {
            print(strNumber[num[0]]);
            return;
        }
 
        while (num != '') {
            if (num > 0) {
                if (num[0] == 0) {
                    if (num.length <= 4)
                        print(strNumber[num[0]]);
                } else {
                    print(strNumber[num[0]]);
                }

                if (num[0] > 0 || num.length > 4)
                    print(numberOfWeight[num.length - 1]);
            }

            num = num.substring(1);
            while (num[0] == 0 && num[1] == 0) {
                num = num.substring(1);
            }
        }
    }


    function print(s) {
        document.write(s);
    }
</script>
</body>
</html>